/*
 * Config.h
 *
 *  Created on: Jan 28, 2010
 *      Author: jgrande
 */

#ifndef CONFIG_H_
#define CONFIG_H_

#include <string>

#include "../../Framework/IO/log.h"
#include "../../Framework/Common/utiles.h"
#include "../../Framework/Common/TemplateSingleton.h"

#include "CommonTypes.h"

#ifndef PKGDATADIR
#define PKGDATADIR "."
#endif

#define CONFIG_FILENAME PKGDATADIR"/middleware.conf"
#define HOSTS_FILENAME PKGDATADIR"/hosts"

using std::string;

using middleware::common::Direccion;
using middleware::common::DireccionTCP;

class Config;

typedef SingletonTemplate<Config> ConfigSingleton;

class Config : Singleton {
private:
	config_t config;

	config_t hosts;

	Direccion dirLocal;

	Config();

	friend Config& ConfigSingleton::instance();

	void loadDirLocal();

public:
	template<typename T>
	T get(string key) {
		return Utiles::fromString<T>(config[key]);
	}

	DireccionTCP getHost(Direccion mwdir);

	Direccion getDirLocal() { return dirLocal; }
};

#endif /* CONFIG_H_ */
